<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Mar 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/jobseeker/tmpl/jobcat.php
 ^ 
 * Description: template view for job categories 
 ^ 
 * History:		NONE
 ^ 
 */
 
 defined('_JEXEC') or die('Restricted access');
  global $mainframe;
  $document =& JFactory::getDocument();
   $document->addStyleSheet('components/com_wrecruit/css/'.$this->config['theme']);

	$link = "index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=jobcat&Itemid=".$this->Itemid;
if (isset($this->userrole->rolefor)){
	if ($this->userrole->rolefor != ''){
		if ($this->userrole->rolefor == 2) // job seeker
			$allowed = true;
		else
			$allowed = false;
	}else{
		$allowed = true;
	}
}else $allowed = true; // user not logined
?>
<?php if ($this->config['offline'] == '1'){ ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	<?php echo $this->config['title']; ?></td></tr>
	<tr><td height="25"></td></tr>
	<tr><td class="wrecruitmsg">
		<?php echo $this->config['offline_text']; ?>
	</td></tr>
</table>	
<?php }else{ ?>

<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	
		<?php echo $this->config['title']; ?>
	</td>
	</tr>
	<tr><td height="23"></td></tr>
	<?php if ($this->config['cur_location'] == 1) {?>
	<tr><td height="0"></td></tr>
	<tr><td class="curloc">
		<?php echo JText::_('JS_CUR_LOC'); ?> : <?php echo JText::_('JS_JOB_CATEGORIES'); ?>
	</td></tr>
	<?php } ?>
	<tr><td>
			<?php 
			if (sizeof($this->jobseekerlinks) != 0){
				echo '<div id="toplinks"><ul>';
				foreach($this->jobseekerlinks as $lnk)	{ ?>
					<span <?php if($lnk[2] == 1)echo 'class="first"'; elseif($lnk[2] == -1)echo 'class="last"';  ?>>
						<a href="<?php echo $lnk[0]; ?>"> <?php echo $lnk[1]; ?></a>
					</span>
				<?php }
				echo '<ul></div>';			
			} 
			?>
	</td></tr>	
	<?php if ($allowed == true) { ?>
		<tr><td height="3"></td></tr>
		<tr><td>
		<form action="<?php echo JRoute::_($link); ?>" method="post" name="adminForm">
		<?php
			require_once( 'job_filters.php' );
		?>	
		</form>
		</td></tr>
	<?php } ?>
	<tr><td height="3"></td></tr>
	<tr><td class="<?php echo $this->theme['heading']; ?>" align="center">
		<?php echo JText::_('JS_JOB_CATEGORIES'); ?> 
	</td></tr>

	<tr><td height="3"></td></tr>
</table>

<?php
if ($allowed == true) { 
?>

	<table cellpadding="3" cellspacing="0" border="0" width="100%" >
		<?php
		$trclass = array($this->theme['odd'], $this->theme['even']);
                $count =1;
                $isodd =1;
                $noofcols =$this->config['categories_colsperrow'];
                $colwidth = round(100 / $noofcols);
		if ( isset($this->application) ){
			foreach($this->application as $category)	{
                                    if ($count == 1){
                                            $isodd = 1 - $isodd;
                                            echo '<tr class="'.$trclass[$isodd].'">';
                                    }
                                    $lnks = 'index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=list_jobs&jobcat='. $category->id .'&Itemid='.$this->Itemid;
                                    $lnks = JRoute::_($lnks);
                                    ?>
                                            <td width="<?php echo $colwidth; ?>%" align="left"><a href="<?php echo $lnks; ?>" ><?php echo $category->cat_title; ?> (<?php echo $category->catinjobs; ?>)</a></td>
                                    <?php
                                    if ($count == $noofcols){
                                            echo '</tr>';
                                            $count = 0;
                                    }
                                    $count++;
                        }
			
		}
                if ($count-1 < $noofcols){
                        for ($i = $count; $i <= $noofcols; $i++){
                            echo '<td></td>';
                        }
                        echo '</tr>';
                }
		
		?>		
		
	</table>
<?php
} else{ // not allowed job posting
	//Update by Vireak on 09/08/2012
	//Add frame to this warning and some styling
	//---------------------
	echo '<div class="box-list"><div class="head-title"><h2>Oop!</h2></div>';
	echo '<span class="wr_info"><p>'.JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW').'</p>';
	echo '<p>This page is reserved for the authorized job seekers only. </p></span>';
	echo '</div>';
	//---------------------
}
}//ol
?>
<div width="100%">
<?php 
if($this->config['fr_cr_txsh']) {
	echo 
	'<table width="100%" style="table-layout:fixed;">
		<tr><td height="15"></td></tr>
		<tr><td style="vertical-align:top;" align="center">'.$this->config['fr_cr_txa'].$this->config['fr_cr_txb'].'</td></tr>
	</table>';
}	
?>
</div>
